package com.wenjie.controller.sys;


import com.wenjie.login.annotations.WJLong;
import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.SysAdmin.SysAdminUpOrAddVo;
import com.wenjie.original.entity.vo.SysAdmin.SysAdminVo;
import com.wenjie.original.service.ISysAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("后台用户管理")
@RestController
@RequestMapping("/api/sysAdmin")
public class SysAdminController {

    @Autowired
    private ISysAdminService sysAdminService;

    @WJLong("测试一下")
    @ApiOperation("查询接口")
    @PostMapping("/list")
    public RestBaseVo<SysAdminVo.ResVo> list(@RequestBody @Validated SysAdminVo.SelVo selVo) {
        return sysAdminService.list(selVo, SysAdminVo.ResVo.class);
    }

    @ApiOperation("添加接口")
    @PostMapping("/add")
    public void add(@RequestBody @Validated SysAdminUpOrAddVo.AddVo addVo) {
        sysAdminService.cusSave(addVo);
    }

    @ApiOperation("修改接口")
    @PostMapping("/up")
    public void up(@RequestBody @Validated SysAdminUpOrAddVo.UpVo upVo) {
        sysAdminService.cusUpdateById(upVo);
    }

    @ApiOperation("删除接口")
    @PostMapping("/del")
    public void del(@RequestBody @Validated Long id) {
        sysAdminService.removeById(id);
    }

}
